﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZBJF.Warranty.Common.Enums.InsuranceWarranty;
using ZBJF.Warranty.Model;
using ZBJF.Warranty.Model.ViewModel.InsuranceWarranty;
using ZBJF.Warranty.Model.ViewModel.Order;

namespace ZBJF.Warranty.BLL
{
    public partial class InsuranceWarrantyRecordServiceUserService
    {
        public SystemUser LoadLastServiceUser(long warrantyRecordeId)
        {
            return LoadEntities(o => o.InsuranceWarrantyRecordID == warrantyRecordeId)
                .OrderByDescending(o => o.CreatedTime).Select(o => o.SystemUser).FirstOrDefault();
        }

        public InsuranceWarrantyRecordServiceUser Load(long warrantyRecordeId, long? transferOrderServiceUserID, long takeOverOrderServiceUserID)
        {
            return LoadEntities(n => n.InsuranceWarrantyRecordID == warrantyRecordeId && n.TransferOrderServiceUserID == transferOrderServiceUserID && n.TakeOverOrderServiceUserID == takeOverOrderServiceUserID).FirstOrDefault();
        }
    }
}
